package week5.day30;

import java.util.ArrayList;
import java.util.Date;

/**
 * @Author fengzihao
 * @Date 2024-05-14 19:45
 */
public class OrderManage {
    public static void main(String[] args) {
        //新建五条订单放入
        Order order1 = new Order(1,200,new Date(1640995200000L),"未付款",new Date(1640995201000L));
        Order order2 = new Order(2,2000,new Date(1673823296000L),"已付款",new Date(1673823297000L));
        Order order3 = new Order(3,1230,new Date(1672444798000L),"已发货",new Date(1672444798000L));
        Order order4 = new Order(4,30,new Date(1688091930000L),"已评价",new Date(1688091931000L));
        Order order5 = new Order(5,78733,new Date(1677468920000L),"已付款",new Date(1677468921000L));
        ArrayList<Order> orderArrayList = new ArrayList<>();
        orderArrayList.add(order1);
        orderArrayList.add(order2);
        orderArrayList.add(order3);
        orderArrayList.add(order4);
        orderArrayList.add(order5);
        // 找出下单时间最早的订单，并打印
        Order earlyOrder = orderArrayList.get(0);
        long dateTag = earlyOrder.time.getTime();
        for (Order order :orderArrayList){
            if (order.time.getTime()<dateTag){
                dateTag = order.time.getTime();
                earlyOrder = order;
            }
        }
        System.out.println(earlyOrder);
        // 找出订单状态是已付款的
        ArrayList<Order> paidOrders = new ArrayList<>();
        for (Order order :orderArrayList){
            if ("已付款".equals(order.status)){
                paidOrders.add(order);
            }
        }
        System.out.println(paidOrders);
        // 找出订单金额超过200的，并且订单状态是已发货
        ArrayList<Order> deliveredAndMoneyMoreThan200Orders = new ArrayList<>();
        for (Order order :orderArrayList){
            if ("已发货".equals(order.status)&&order.money>200){
                deliveredAndMoneyMoreThan200Orders.add(order);
            }
        }
        System.out.println(deliveredAndMoneyMoreThan200Orders);
    }
}
class Order{
    int orderId;
    double money;
    Date time;
    String status;
    Date updateTime;

    public Order(int orderId, double money, Date time, String status, Date updateTime) {
        this.orderId = orderId;
        this.money = money;
        this.time = time;
        this.status = status;
        this.updateTime = updateTime;
    }

    @Override
    public String toString() {
        return "Order{" +
                "orderId=" + orderId +
                ", money=" + money +
                ", time=" + time +
                ", status='" + status + '\'' +
                ", updateTime=" + updateTime +
                '}';
    }
}
